#include "Login_v1.h"
#include <string>

void func(_INPUT_DESC_& type, BOOL b) {

	if (type.type == mouse)
	{
		switch (type.ms.state)
		{
		case 0:
			SetCursorPos(type.ms.x_abs * 1920, type.ms.y_abs * 1080);
			break;
		case 1:
			mouse_event(MOUSEEVENTF_LEFTDOWN, 0, 0, 0, 0);  
			printf("[TEST]MOUSEEVENTF_LEFTDOWN !!!\n");
			break;
		case 2:
			mouse_event(MOUSEEVENTF_LEFTUP, 0, 0, 0, 0);
			printf("[TEST]MOUSEEVENTF_LEFTUP !!!\n");
			break;
		default:
			break;
		}
	}
	else if (type.type == keyboard)
	{
		if (type.kb.len == 1)
		{
			keybd_event(type.kb.buff[0], 0, 0, 0);
			keybd_event(type.kb.buff[0], 0, KEYEVENTF_KEYUP, 0);
		}
		else if (type.kb.len == 2)
		{
			keybd_event(type.kb.buff[0], 0, 0, 0);
			keybd_event(type.kb.buff[1], 0, 0, 0);
			keybd_event(type.kb.buff[1], 0, KEYEVENTF_KEYUP, 0);
			keybd_event(type.kb.buff[0], 0, KEYEVENTF_KEYUP, 0);
		}

	}

	//printf("[TEST]Enter func !!!\n");

	//SetCursorPos(type.ms.x_abs, type.ms.y_abs);
	//mouse_event(type.ms.state, type.ms.x_abs,type.ms.y_abs, type.ms.wheel, type.ms.button);
}

int main() {

	_LOGIN_CONF_ rf;
	rf.version = 20200221;
	//std::function<void(_INPUT_DESC_&, BOOL)> func;
	rf.input_handle.func = func;
	std::shared_mutex* mutex_ptr;
	rf.input_handle.mutex_ptr = new std::shared_mutex;

	RECT rect;
	rect.bottom = 1080;
	rect.left = 0;
	rect.right = 1920;
	rect.top = 0;

	_MT_SAFE_<RECT>* mt = new _MT_SAFE_<RECT>();
	mt->set(rect);

	rf.input_handle.rect_ptr = mt;

	DL_PARAM_IN input = (DL_PARAM_IN)&rf;
	// 
	// 	login._config(input);
	// 	login._start();

	Login_v1 *login = new Login_v1();
	login->exec(COMMON_CONFIG, input);

	system("pause");
	return 1;
}